<template>
  <div>
    <van-field v-model="name" label="名字" />
    <inject></inject>
    <InjectProps :nameArray="nameArray" :nameObj="nameObj"></InjectProps>
  </div>
</template>
<script lang="ts">
import { defineComponent, getCurrentInstance, provide, ref } from 'vue'
import Inject from './inject.vue'
import InjectProps from './injectProps.vue'
export default defineComponent({
  name: 'Provide',
  components: { Inject, InjectProps },
  setup() {
    const name = ref('李四')
    const nameArray = ref(['张三', '李四', '王五'])
    const nameObj = ref({ name: '张三', id: '001' })
    const changeName = (param1: string) => {
      name.value = param1
      nameArray.value = ['张三', '李四', '王五', '赵六']
      nameObj.value = { name: '李四', id: '001' }
    }
    provide('reload', changeName)
    return {
      name,
      nameArray,
      nameObj
    }
  }
})
</script>
